import Mock from 'mockjs'

const Random = Mock.Random

export default [
  {
    url: '/api/search/blog',
    method: 'get',
    response: ({ query }) => {
      const { page = 1, pageSize = 10 } = query
      const list = Array(pageSize).fill(0).map(() => ({
        id: Random.id(),
        title: Random.title(),
        content: Random.paragraph(),
        author: Random.cname(),
        createTime: Random.datetime()
      }))
      
      return {
        code: 200,
        data: {
          total: 100,
          list
        },
        message: '搜索成功'
      }
    }
  },
  {
    url: '/api/search/user',
    method: 'get',
    response: ({ query }) => {
      const { page = 1, pageSize = 10 } = query
      const list = Array(pageSize).fill(0).map(() => ({
        id: Random.id(),
        username: Random.cname(),
        avatar: Random.image('100x100')
      }))
      
      return {
        code: 200,
        data: {
          total: 50,
          list
        },
        message: '搜索成功'
      }
    }
  }
]